home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 402_01 / cforms-2.2 / example / validate.frm < prev   
Encoding:
Text File  |  1993-07-20  |  1.1 KB  |  56 lines

  1. /*
  2.  * Test application for CForms.
  3.  * @(#) validate.frm,v 1.3 1993/07/21 01:26:14 lasse Exp
  4.  */
  5.  
  6. Viewport view {
  7.     Pos 0,0;
  8.     Size 80, 23;
  9. }
  10.  
  11. Event Key DOWN  { fld_move(fld_down(NULL));  }
  12. Event Key UP    { fld_move(fld_up(NULL));    }
  13. Event Key ESC   { pic_leave(); }
  14.  
  15. Picture Validate Viewport View
  16. {
  17.     Literal Center, 1, "Test of a validation EXIT  event";
  18.     Literal +0, 2,     "--------------------------------";    
  19.     Literal Center, Max, "(Press ESC to exit)";
  20.  
  21.     Field Date {
  22.     Pos 35, 8;
  23.     Type Char(8);
  24.     LValue "Enter year of birth (yy-mm-dd): ";
  25.     Event Exit {
  26.         int a, b, c;
  27.         char buf[50];
  28.         if (sscanf(fld_get(NULL), "%2d-%2d-%2d", &a, &b, &c) != 3) {
  29.         message("Illegal format");
  30.         fld_move(NULL);
  31.         }
  32.         else
  33.         {
  34.         sprintf(buf, "%02d-%02d-%02d", a, b, c);
  35.         fld_set(NULL, buf);
  36.         }
  37.     }
  38.     }
  39.  
  40.     Field Sex {
  41.     Pos +0, +1;
  42.     Type Char(8);
  43.     LValue "Male/Female: ";
  44.     Uppercase;
  45.     Event Exit {
  46.         if (strequ(fld_get_trimmed(NULL), "male") != 0 &&
  47.             strequ(fld_get_trimmed(NULL), "female") != 0)
  48.         {
  49.         message("Must be male or female (%s)", fld_get_trimmed(NULL));
  50.         fld_set(NULL, "");
  51.         fld_move(NULL);
  52.         }
  53.     }
  54.     }
  55. }
  56.